package com.ktjiaoyu.controller;

import com.ktjiaoyu.pojo.SysUser;
import com.ktjiaoyu.service.SysUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController //@responsyBody+@controller
public class SysUserController {
    @Resource
    SysUserService sysUserService;

//    @RequestMapping("/getUser")
//    @RequestMapping(value = "/sysUser/{id}",method = RequestMethod.GET)
    @GetMapping("/sysUser/{id}")
    public SysUser getUser(@PathVariable Long id){
        return sysUserService.getUser(id);
    }

    //@RequestMapping("/findAllUsers")
//    @RequestMapping(value = "/sysUser",method = RequestMethod.GET)
    @GetMapping("/sysUser")
    public List<SysUser> findAllUsers(){
        return sysUserService.findAllUsers();
    }

    //@RequestMapping("/addUser")
//    @RequestMapping(value = "/sysUser",method = RequestMethod.POST)
    @PostMapping("/sysUser")
    public void addUser(SysUser sysUser){
        sysUserService.addUser(sysUser);
    }

    //@RequestMapping("/updateUser")
//    @RequestMapping(value = "/sysUser",method = RequestMethod.PUT)
    @PutMapping("/sysUser")
    public void updateUser(SysUser sysUser){
        sysUserService.updateUser(sysUser);
    }

   // @RequestMapping("/deleteUser")
//    @RequestMapping(value = "/sysUser",method = RequestMethod.DELETE)
    @DeleteMapping("/sysUser")
    public void deleteUser(Long id){
        sysUserService.deleteUser(id);
    }
}
